home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #ifndef _SERVER_H_
- #define _SERVER_H_
-
- #include "vroom.h"
-
- #define VROOM_GROUP "224.0.1.2"
-
- #define VROOM_ALL_PLAYERS (-1)
- #define CLIENT_PACKET_BASE_ID 0x56524930
- #define SERVER_PACKET_BASE_ID 0x56524f30
-
- #define CLIENT_P_SPEED ( CLIENT_PACKET_BASE_ID | 0 )
- #define CLIENT_P_INFO ( CLIENT_PACKET_BASE_ID | 1 )
- #define CLIENT_P_NAME ( CLIENT_PACKET_BASE_ID | 2 )
- #define CLIENT_P_MESSAGE ( CLIENT_PACKET_BASE_ID | 3 )
-
- #define CLIENT_INFO_QUIT 1
- #define CLIENT_INFO_JOIN 2
- #define CLIENT_INFO_ACCEPT 3
- #define CLIENT_INFO_UPDATE 4
- #define CLIENT_INFO_COURSE_SEL 5
- #define CLIENT_INFO_COURSE_ACK 6
- #define CLIENT_INFO_COURSE_REQ 7
-
- #define CLIENT_TIMEOUT (5.0f) /* client must speak every 5 seconds */
- #define CLIENT_UPDATE_FREQ (2.0f) /* client should speak every 2 secs */
-
- #define SERVER_TIMEOUT (5.0f) /* server must speak every 5 seconds */
-
- #define VROOM_SERVER_INPUT_PORT 5138
- #define VROOM_SERVER_INPUT_SERVICE "sgi-vroom-server"
-
- /*
- * Server input packets.
- */
- typedef struct {
- long type ;
- long id ;
- } inBasePacket ;
-
- typedef struct {
- long type ;
- long id ;
- long playerNumber ;
- long steer ;
- float speed ;
- } inSpeedPacket ;
-
- typedef struct {
- long type ;
- long id ;
- int option ;
- int choice ;
- } inInfoPacket ;
-
- typedef struct {
- long type ;
- long id ;
- char name[VROOM_NAMELEN] ;
- } inNamePacket ;
-
- typedef struct {
- long type ;
- long id ;
- char msg[VROOM_MSGLEN] ;
- } inMsgPacket ;
-
- typedef union {
- inBasePacket base ;
- inSpeedPacket speed ;
- inInfoPacket info ;
- inNamePacket name ;
- inMsgPacket msg ;
- } inputPacket ;
-
-
- /*
- * Server output packets.
- */
- typedef struct {
- long type ;
- long id ;
- } outBasePacket ;
-
- #define SERVER_P_COURSE ( SERVER_PACKET_BASE_ID | 0 )
- #define SERVER_P_STATUS ( SERVER_PACKET_BASE_ID | 1 )
- #define SERVER_P_ACK ( SERVER_PACKET_BASE_ID | 2 )
- #define SERVER_P_RACE ( SERVER_PACKET_BASE_ID | 3 )
- #define SERVER_P_NAME ( SERVER_PACKET_BASE_ID | 4 )
- #define SERVER_P_MESSAGE ( SERVER_PACKET_BASE_ID | 5 )
-
- #define ACK_ST_FAIL 0x01
- #define ACK_ST_PLAYER 0x02
- #define ACK_ST_CANDIDATE 0x03
- #define ACK_ST_WAIT 0x04
- #define ACK_ST_DROP 0x05
- #define ACK_ST_COURSE_VOTE 0x06
- #define ACK_ST_COURSE_CHOSEN 0x07
-
- #define SERVER_ST_INIT 0x00
- #define SERVER_ST_COURSE_SEL 0x01
- #define SERVER_ST_COURSE_ACK 0x02
- #define SERVER_ST_PRE_TRIAL 0x03
- #define SERVER_ST_TRIAL 0x04
- #define SERVER_ST_POST_TRIAL 0x05
- #define SERVER_ST_PRE_RACE 0x06
- #define SERVER_ST_RACE 0x07
- #define SERVER_ST_POST_RACE 0x08
- #define SERVER_ST_RESULTS 0x09
- #define SERVER_ST_QUIT 0x0a
-
- typedef struct {
- long type ;
- long id ;
- long status ;
- long nPlayers ;
- long playerId[MAX_PLAYERS] ;
- long selection[MAX_PLAYERS] ;
- } outStatusPacket ;
-
- typedef struct {
- long type ;
- long id ;
- long mode ;
- float time ;
- long status[MAX_PLAYERS] ;
- float x[MAX_PLAYERS] ;
- float y[MAX_PLAYERS] ;
- float z[MAX_PLAYERS] ;
- float thetaDeg[MAX_PLAYERS] ;
- float roll[MAX_PLAYERS] ;
- float headingDeg[MAX_PLAYERS] ;
- float totalDis[MAX_PLAYERS] ;
- float indTime[MAX_PLAYERS] ;
- float desiredSpeed[MAX_PLAYERS] ;
- float lane[MAX_PLAYERS] ;
- char position[MAX_PLAYERS] ;
- } outRacePacket ;
-
- typedef struct {
- char id[4] ;
- float data[8] ;
- } TrackDetailQuad ;
-
- typedef struct {
- long type ;
- long id ;
- long courseId ;
- long size ;
- int nLaps ;
- char name[MAX_COURSE_NAME] ;
- float recLap ;
- char recLapOwner[VROOM_NAMELEN];
- float recRace ;
- char recRaceOwner[VROOM_NAMELEN];
- TrackDetailQuad detail[MAX_COURSE_SIZE/4] ;
- } outCoursePacket ;
-
- typedef struct {
- long type ;
- long id ;
- long targetId ;
- long status ;
- long data ;
- } outAckPacket ;
-
- typedef struct {
- long type ;
- long id ;
- long nPlayer ;
- char name[VROOM_NAMELEN] ;
- } outNamePacket ;
-
- typedef struct {
- long type ;
- long id ;
- long nPlayer ;
- char msg[VROOM_MSGLEN] ;
- } outMsgPacket ;
-
- typedef union {
- outBasePacket base ;
- outStatusPacket status ;
- outRacePacket race ;
- outCoursePacket course ;
- outAckPacket ack ;
- outNamePacket name ;
- outMsgPacket msg ;
- } outputPacket ;
-
- /* BEGIN PROTOTYPES server.c */
- int addToCourseList( outCoursePacket *packet ) ;
- void broadcastMsgPacket( long nPlayer, char *msg ) ;
- void checkPorts( void ) ;
- void clearCourseList( void ) ;
- void clientAckCourse( long id ) ;
- void clientChoseCourse( long id, int choice ) ;
- void closeServer( void ) ;
- outCoursePacket * findCourseInList( char *name ) ;
- outCoursePacket * findCourseInListById( long courseId ) ;
- int getPort( char *servName, int defaultPort ) ;
- char * hostNameFromId( long id, int showIp ) ;
- int initLocalServer( void ) ;
- void serverRun( void ) ;
- void setServerCourseLabel( char *fmt, ... ) ;
- void setServerForNextGame( void ) ;
- void updateServerCourseLabel( int np ) ;
- /* END PROTOTYPES server.c */
-
- #endif /* !_SERVER_H_ */
-